Skip to content

Fix error with ambient type when running Universal #853

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2020

Conversation

JohannesHuster
Copy link

Hi everyone,

this PR solves issue #773. Since this PR is a bit of a workaround, I wanted to share a few details on what I found on the issue, in case you want to search for a better solution. So please feel free to ignore the following ;-)

With View Engine and strictMetadataEmit enabled, using ambient types did throw a build-time error (Could not resolve type), even when correctly injecting a provider with @Inject(). Also see issue angular/angular#20351. This seems to have been fixed with Ivy: angular/angular#23395 (comment)

Since Ivy seems to be doing something different here with ambient types, I thought it might be a general problem with a mixed (and correct) setup like the following:

  • View Engine lib uses ambient type for constructor param
  • App has Ivy enabled
  • Running with Universal

Unfortunately, I am not able to reproduce the behaviour with a clean Angular workspace and just that setup. So something else seems to be involved in producing the error. And this is as far as I got for now.

P.S. Having strictMetadataEmit enabled did help me fix this issue, because it throws an error during build-time when using an ambient type. Just wanted to let you know, in case enabling it could help you in your workflow.

Thank you for the great library!

@JohannesHuster JohannesHuster changed the title Fix issue with ambient type in constructor when running Universal wit… Fix error with ambient type when running Universal Jun 3, 2020
@JohannesHuster
Copy link
Author

Please be aware that I have opened an additional PR (#855) for this issue. There might be tradeoffs to each solution for you, so I leave both open for now.

@manfredsteyer manfredsteyer merged commit c095b1d into manfredsteyer:master Jun 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants